﻿///////////////////////////////////////////////////////////////////////////////
// File:        TimeUtil.hpp
// Author:      671643387@qq.com
// Description:
///////////////////////////////////////////////////////////////////////////////

#ifndef NIO_BASE_TIMEUTIL_HPP_
#define NIO_BASE_TIMEUTIL_HPP_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <boost/noncopyable.hpp>
#include <nio/Types.hpp>

namespace nio
{
    namespace base
    {
        class TimeUtil : public boost::noncopyable
        {
        public:
            static base::time_t fromStartup(void)
            {
#if defined(__WINDOWS__)
                return ::GetTickCount();
#elif defined(__LINUX__)
                struct timespec time;
                clock_gettime(CLOCK_MONOTONIC, &time);
                return time_t(time.tv_nsec / 1000000) + time_t(time.tv_sec * 1000);
#endif
            }
        };
    }
}

#endif //NIO_BASE_TIMEUTIL_HPP_
